# coding:utf-8
import logging
import time
from config.confManage import dir_manage
from utils.common.mkDir import mk_dir
class Log(object):

    def __init__(self):
        """
        日志配置
        """
        log_path = dir_manage('${pro_dir}$') + dir_manage('${log_dir}$')
        now = time.strftime('%Y-%m-%d')
        logfile = log_path + "{}".format(now) + ".log"
        logfile_debug = log_path + "{}".format(now)+"_debug" + ".log"
        mk_dir(log_path)
        # logfile_err = log_path + "{}-".format(now) + 'error.log'
        self.logger = logging.getLogger()
        self.logger.setLevel(logging.DEBUG)
        self.logger.handlers = []
        fh_debug = logging.FileHandler(logfile_debug, mode='a+', encoding='utf-8')
        fh_debug.setLevel(logging.DEBUG)
        fh = logging.FileHandler(logfile, mode='a+',encoding='utf-8')
        fh.setLevel(logging.INFO)

        # fh_err = logging.FileHandler(logfile_err, mode='a+',encoding='utf-8')
        # fh_err.setLevel(logging.ERROR)
        formatter = logging.Formatter("%(levelname)-8s%(asctime)s  %(filename)s:%(lineno)d %(message)s")
        fh.setFormatter(formatter)
        fh_debug.setFormatter(formatter)
        # fh_err.setFormatter(formatter)
        self.logger.addHandler(fh)
        self.logger.addHandler(fh_debug)
        # self.logger.addHandler(fh_err)

if __name__ == '__main__':
    Log()
    logging.debug("111")



